package cn.zzm.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * TODO().
 *
 * <p>TODO().
 *
 * <p>版权所有:Copyright (c) 2019<br/>
 *
 * @author 周昭名
 * @version V1.0
 * @since 2019/7/25 18:35
 */
@Component
@Slf4j
public class MqListener {

    /**
      *
      *TODO(pool点对点).
      *
      *<p>TODO().
      *
      *@return
      *@author 周昭名
      *@since 2019/7/25 19:38
    */
    @JmsListener(destination = "remoteQueueTest",containerFactory = "jmsRemoteQueueListenerContainerFactory",concurrency = "2")
    @SendTo("reply.remoteQueueTest")
    public String remoteQueueListernerTest(String msg){
        String replyMsg = "收到队列：{remoteQueueTest}的消息：{"+msg+"}";
        log.info(replyMsg);
        return replyMsg;
    }

    /**
      *
      *TODO(pool订阅主题示例).
      *
      *<p>TODO().
      *
      *@return
      *@author 周昭名
      *@since 2019/7/26 12:13
    */
    @JmsListener(destination = "remoteTopicTest",containerFactory = "jmsRemoteTopicListenerContainerFactory",concurrency = "2")
    @SendTo("reply.remoteTopicTest")
    public String remoteTopicListernerTest(String msg){
        String replyMsg = "收到主题：{remoteTopicTest}的消息：{"+msg+"}";
        log.info(replyMsg);
        return replyMsg;
    }

    /**
      *
      *TODO(cache主题订阅).
      *
      *<p>TODO().
      *
      *@return
      *@author 周昭名
      *@since 2019/7/26 12:15
    */
    @JmsListener(destination = "cloudTopicTest",containerFactory = "jmsCloudTopicListenerContainerFactory",concurrency = "2")
    @SendTo("reply.cloudTopicTest")
    public String cloudTopicListernerTest(String msg){
        String replyMsg = "收到主题：{cloudTopicTest}的消息：{"+msg+"}";
        log.info(replyMsg);
        return replyMsg;
    }

    /**
     *
     *TODO(cache主题订阅).
     *
     *<p>TODO().
     *
     *@return
     *@author 周昭名
     *@since 2019/7/26 12:15
     */
    @JmsListener(destination = "cloudTopicTest",containerFactory = "jmsCloudDurableTopicListenerContainerFactory",concurrency = "2")
    @SendTo("reply.cloudTopicTest")
    public String cloudDurableTopicListernerTest(String msg){
        String replyMsg = "收到主题：{cloudTopicTest}的消息：{"+msg+"}";
        log.info(replyMsg);
        return replyMsg;
    }

}
